package com.mrtop.jigsawapp;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v4.widget.SearchViewCompat.OnCloseListenerCompat;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends Activity {
	/** Called when the activity is first created. */
	private MediaPlayer mp;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		Button btnexit = (Button)findViewById(R.id.ExitButton);
		mp = MediaPlayer.create(this, R.raw.banana_song);
		mp.start();
		btnexit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
				System.exit(0);
			}
		});
		Button play = (Button) findViewById(R.id.PlayButton);
		//play.setBackgroundDrawable(getResources().getDrawable(R.drawable.buttonstyle));
		//play.setBackgroundColor(Color.parseColor("#fcb40a"));
		play.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(), Levels.class);
				//send data to play layout
				//intent.putExtra("LEVEL","01");
				finish();
				startActivity(intent);
			}
		});

		
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main, menu);

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.exitmenu:
			finish();
			break;
		case R.id.helpmenu:
			Intent intent = new Intent(getApplicationContext(), Help.class);
			finish();
			startActivity(intent);
			break;
		case R.id.creditsmenu:
			Intent i = new Intent(getApplicationContext(), Creadits.class);
			finish();
			startActivity(i);
			break;
		}
		return super.onOptionsItemSelected(item);
	}
	
	public void onPause(){
		super.onPause();
		mp.pause();
		finish();
	}
	
}